﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="FyysilineIsikOtsing", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(FyysilineIsikOtsing))]
    public class FyysilineIsikOtsingSerializer : global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IsikOtsingSerializer {
        
        public FyysilineIsikOtsingSerializer(IFyysilineIsikOtsing clazz) : 
                base(clazz) {
        }
        
        protected new IFyysilineIsikOtsing clazz {
            get {
                return ((IFyysilineIsikOtsing)(base.clazz));
            }
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.SuguKL!=null) {
                Writer.WriteStartElement("SuguKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.SuguKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("Eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SynniKP!=null) {
                Writer.WriteStartElement("SynniKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.SynniKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SurmaKP!=null) {
                Writer.WriteStartElement("SurmaKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.SurmaKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SynniKPVahemikuLoppKP!=null) {
                Writer.WriteStartElement("SynniKPVahemikuLoppKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.SynniKPVahemikuLoppKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiNR!=null) {
                Writer.WriteStartElement("DokumendiNR");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiNR))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ElukohtCSV!=null) {
                Writer.WriteStartElement("ElukohtCSV");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ElukohtCSV))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EmaNimi!=null) {
                Writer.WriteStartElement("EmaNimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmaNimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsaNimi!=null) {
                Writer.WriteStartElement("IsaNimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsaNimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeisedNimed!=null) {
                Writer.WriteStartElement("TeisedNimed");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TeisedNimed))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiTyypKL!=null) {
                Writer.WriteStartElement("DokumendiTyypKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.DokumendiTyypKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokumendiNimetus!=null) {
                Writer.WriteStartElement("DokumendiNimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokumendiNimetus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KodakondsusKL!=null) {
                Writer.WriteStartElement("KodakondsusKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.KodakondsusKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MitmikKodakondsusKL!=null) {
                Writer.WriteStartElement("MitmikKodakondsusKL");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("long", "http://www.w3.org/2001/XMLSchema", clazz.MitmikKodakondsusKL.Count);
                for (int x = 0; ((clazz.MitmikKodakondsusKL != null) 
                            && (x < clazz.MitmikKodakondsusKL.Count)); x = (x + 1)) {
                    if (clazz.MitmikKodakondsusKL[x]!=null) {
                        Writer.WriteStartElement("item");
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.MitmikKodakondsusKL[x]))).ToString());
                        Writer.WriteEndElement();
                    }
                }
                Writer.WriteEndElement();
            }
            if (clazz.KaristatudIsik!=null) {
                Writer.WriteStartElement("KaristatudIsik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.KaristatudIsik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AmetikohaNimetus!=null) {
                Writer.WriteStartElement("AmetikohaNimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AmetikohaNimetus))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="SuguKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>FyysilineIsikOtsing>SuguKL");
                }
                clazz.SuguKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("SuguKL")).Value;
            }
            if (Reader.LocalName=="Eesnimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Eesnimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="SynniKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.SynniKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("SynniKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="SurmaKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.SurmaKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("SurmaKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="SynniKPVahemikuLoppKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.SynniKPVahemikuLoppKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("SynniKPVahemikuLoppKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="DokumendiNR") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiNR = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("DokumendiNR")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ElukohtCSV") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ElukohtCSV = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ElukohtCSV")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="EmaNimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EmaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EmaNimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="IsaNimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.IsaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("IsaNimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TeisedNimed") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TeisedNimed = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("TeisedNimed")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="DokumendiTyypKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>FyysilineIsikOtsing>DokumendiTyypKL");
                }
                clazz.DokumendiTyypKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("DokumendiTyypKL")).Value;
            }
            if (Reader.LocalName=="DokumendiNimetus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokumendiNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("DokumendiNimetus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="KodakondsusKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>FyysilineIsikOtsing>KodakondsusKL");
                }
                clazz.KodakondsusKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("KodakondsusKL")).Value;
            }
            if (Reader.LocalName=="MitmikKodakondsusKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MitmikKodakondsusKL = new System.Collections.Generic.List<System.Int64?>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("MitmikKodakondsusKL");
                        for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                    && (Reader.LocalName == "item")); ) {
                            if (Reader.IsElementNil()) {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>FyysilineIsikOtsing>MitmikKodakondsusKL>item");
                            }
                            clazz.MitmikKodakondsusKL.Add(new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("item")).Value);
                        }
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="KaristatudIsik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KaristatudIsik = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("KaristatudIsik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AmetikohaNimetus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AmetikohaNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AmetikohaNimetus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
